You’re given a dataframe df_cheeses
containing a list of the price of various cheeses from California. The dataframe has missing values in the price column.
Write a function cheese_median
to impute the median price of the selected California cheeses in place of the missing values. You may assume at least one cheese is not missing its price.
import pandas as pd
def cheese_median(df):
# 以中位數填補Price的缺失值
median_value = df['Price'].median()
df['Price'].fillna(median_value,inplace=True)
return df
嗨,我是 Eva,一位正在努力跨進資料科學領域的女子!
如果有任何不理解、錯誤或其他方法想分享的話,歡迎留言!
喜歡的話,也歡迎按讚訂閱唷!我們明天見!